//
//  LLAdaptHideNavBar.swift
//  LaiLang
//
//  Created by David on 2017/2/5.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class LLAdaptHideNavBar: UINavigationBar {

    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    var navigationItem: UINavigationItem!
    var navigationController: UINavigationController?
    
    init(frame: CGRect, title: String, navigator: UINavigationController?) {
        super.init(frame: frame)
        barTintColor = themeColor
        tintColor = UIColor.white
        barStyle = .black
        navigationController = navigator
        navigationItem = UINavigationItem(title: title)
        navigationItem.leftBarButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "navbar_back"), style: .plain, target: self, action: #selector(LLAdaptHideNavBar.backBtnPress))
        pushItem(navigationItem, animated: false)
        
//        let fakeNavBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 64))
//        view.addSubview(fakeNavBar)
//        fakeNavBar.barTintColor = Fatcat.THEME_COLOR
//        fakeNavBar.barStyle = .Black
//        fakeNavBar.tintColor = UIColor.whiteColor()
//        let fakeNavItem = UINavigationItem(title: title!)
//        let fakeBackButton = UIBarButtonItem()
//        fakeBackButton.title = "    返回"
//        fakeNavItem.leftBarButtonItem = fakeBackButton
//        
//        fakeNavBar.pushNavigationItem(fakeNavItem, animated: false)
    }
    
    func backBtnPress(){
        if navigationController != nil{
            navigationController!.popViewController(animated: true)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
